defmodule Pango.AppProtocol do
    @moduledoc """
        启动成功必须调用 set_start_ok
    """
    @start_ok :start_ok


    @doc """
        设置本进程所属的app启动成功
    """
    def set_start_ok() do
        {:ok, app} = :application.get_application(self())
        Application.put_env(app, @start_ok, :success)
    end


    @doc """
        设置app启动成功
    """
    def set_start_ok(app) do
        Application.put_env(app, @start_ok, :success)
    end


    @doc """
        本进程所属的app是否启动成功
    """
    def start_ok?() do
        {:ok, app} = :application.get_application(self())
        Application.get_env(app, @start_ok) == :success
    end

    @doc """
        pid进程所属的app是否启动成功
    """
    def start_ok?(pid) when is_pid(pid) do
        {:ok, app} = :application.get_application(pid)
        Application.get_env(app, @start_ok) == :success
    end
    def start_ok?(app) when is_atom(app) do
        Application.get_env(app, @start_ok) == :success
    end

end
